package com.xxx.util;


import sun.misc.BASE64Encoder;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Md5Util {

    public static String encodePwdByMd5(String pwd) throws NoSuchAlgorithmException, UnsupportedEncodingException {
        //1获取实例
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        //2获取加密器
        BASE64Encoder base64Encoder = new BASE64Encoder();
        return base64Encoder.encode(md5.digest(pwd.getBytes("utf-8")));
    }

}
